//???????????? ?????? ? ???????	
function RefRowSelector(){
	this.table=null;
	this.row=null;
	this.normalColor="";
	this.selectedColor="silver";
	this.scroller=null;
	this.onchange=null; //?????? ?? ???????
	this.select=function(row){
		if (row==null) return false;
		if (row==this.row){
			return false;
		}
		if (this.row!=null){
			this.row.style.backgroundColor=this.normalColor;	
			//this.row.style.fontWeight="normal";
		}
		this.row=row;
		//alert(this.onchange);
		if(this.onchange) this.onchange();
		
		this.row.style.backgroundColor=this.selectedColor;
		//this.row.style.fontWeight="bold";
		
		if (this.scroller){
			this.scroller.scroll(this.row);
		}	
		return true;
	}
	this.selectFirst=function(){
		var first=this.table.rows[0];
		return this.select(first);	
	}
	this.selectSibling=function(direction){
		if (this.row==null) return;
		var index=this.row.rowIndex;
		if (direction>0) {
			index++;
		}
		if (direction<0) { 
			index--;
		}
		var row=this.table.rows[index]
		return this.select(row);	
	}
	
	this.selectLast=function(){
		if (this.table==null) return;
		var lastRow = this.table.rows[this.table.rows.length-1];
		return this.select(lastRow);
	}
	
	this.parseClick=function(element){
		if (!element) return;
		if (element==this.table) return;
		for(var parent=element;parent;parent=parent.parentElement){
			if (!this.isRow(parent)) continue;
			this.select(parent);
			break;
		} 
	}
	this.isRow=function(element){
		//alert(element.outerHTML);
		if (element.tagName!="TR") return false;
		return true;
	}
	
}	